import request from '@/utils/request'

// 查询设备列表
export function listInstance(query) {
  return request({
    url: '/app-api/device/instance/page',
    method: 'get',
    params: query
  })
}

// 查询设备详细
export function getInstance(id) {
  return request({
    url: '/app-api/device/instance/get?id=' + id,
    method: 'get'
  })
}

// 新增设备
export function addInstance(data) {
  return request({
    url: '/app-api/device/instance/create',
    method: 'post',
    data: data
  })
}

// 修改设备
export function updateInstance(data) {
  return request({
    url: '/app-api/device/instance/update',
    method: 'put',
    data: data
  })
}

// 删除设备
export function delInstance(id) {
  return request({
    url: '/app-api/device/instance/delete?id=' + id,
    method: 'delete'
  })
}

// 设备下拉
export function selectInstance(deviceType) {
    return request({
        url: '/app-api/device/instance/list-select?deviceType=' + deviceType,
        method: 'get'
    })
}

export function startBindCardInstance(deviceId) {
    return request({
        url: `/app-api/device/instance/start-bind-card?deviceId=${deviceId}`,
        method: 'post'
    })
}

export function cancelBindCardInstance(deviceId) {
    return request({
        url: `/app-api/device/instance/cancel-bind-card?device=${deviceId}`,
        method: 'post'
    })
}
// 修改设备
export function updateInstanceProperty(data) {
    return request({
        url: '/app-api/device/instance/update-property',
        method: 'put',
        data: data
    })
}
